<template>
  <div class="wrapper">
    <div style="margin:auto;background-color: #fff;width: 350px;height: 300px;padding: 200px;border-radius: 10px">
      <div style="margin:20px 0;text-align: center;font-size: 24px"><b>Login</b></div>
      <el-input  size="medium" style="height:40px"  prefix-icon="el-icon-user" v-model="user.userName"></el-input>
      <el-input  size="medium" style="height:40px"  prefix-icon="el-icon-lock" show-password v-model="user.password"></el-input>
      <div style="margin:10px 0; text-align: center">
        <el-button type="primary" style="margin-right: 10px" size="medium" autocomplete="off" @click="login">登录</el-button>
        <el-button type="warning" style="margin-left: 10px" size="medium" autocomplete="off" @click="register">注册</el-button>
      </div>
    </div>
  </div>


</template>

<style>
.wrapper{
  display: flex;
  height:100vh;
  background-image: linear-gradient(to bottom right,#FC4668,#3F5EFB);
  overflow: hidden;
}

</style>

<script>
export default {
  name: "Login",
  data(){
    return{
      user:{}
    }
  },
  methods:{
    login(){
      this.request.post("/user/login",this.user).then(res => {

        if(res.code=='200'){
          localStorage.setItem("userDto",JSON.stringify(res.result))
          this.$router.push("/gk")
          this.$message.success("登录成功！")
        }
        else {
          this.$message.error(res.msg)
        }
      })
    },
    register(){
      this.$router.push('/register')
    },
  }
}
</script>

